/**
 * Created with IntelliJ IDEA.
 * Description:
 * User:何人亮
 * Date:2024-06-24
 * 15:20
 */
public class Test {


        public static int removeDuplicates(int[] nums) {
           int left=0;
           int right=nums.length-1;
            for(int i=0;i<=right;i++){
                int count=0;
               while (nums[i]==nums[left]){
                   count++;
                   while (count>1){
                       i--;
                       dele(nums,i,i+1);
                       count--;
                       right--;
                       left=i;
                       i--;
                   }
                   i++;
               }

            }
                  return right+1;
        }

        public static void dele(int[] nums,int i,int j){
            nums[i]=nums[j];
        }




    public static void main(String[] args) {

            int[] nums={0,0,1,1,1,2,2,3,3,4};
            removeDuplicates(nums);
    }
}
